import os
import requests
import json
# command = 'python transE.py' #可以直接在命令行中执行的命令
# r = os.popen(command) #执行该命令
# info = r.readlines()  #读取命令行的输出到一个list
# print(info)
# for  index in range(len(info)):
#     info[index]=repr(info[index])
# print(info)
#获取实验输出到微信公众号上
def get_print(variable,epoch=0,interval=0):
    if  interval!=0 and epoch%interval!=1:# 间隔interval epoch输出
        return
    token = '1bcc82870db5428fb49315b2126095d8' #在pushpush网站中可以找到
    title= '我的transE实验' #改成你要的标题内容
    content =variable #改成你要的正文内容
    url = 'http://www.pushplus.plus/send'
    data = {
        "token":token,
        "title":title,
        "content":content,
        "channel":"cp",
        "webhook":"123456"
    }
    body=json.dumps(data).encode(encoding='utf-8')
    headers = {'Content-Type':'application/json'}
    requests.post(url,data=body,headers=headers)